package com.sqlcheck.dto.ai;

import lombok.Data;
import lombok.Builder;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * AI规则验证请求DTO
 * 包含完整的SQL语句和规则分析上下文信息，发送给AI进行验证
 * 
 * @author Claude
 * @version v4.2
 * @since 2025-09-04
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class RuleVerificationRequest {

    private Long taskId;                    // 任务ID
    private String sourceDbType;            // 源数据库类型
    private String targetDbType;            // 目标数据库类型
    private List<StatementVerificationItem> statements; // 待验证的SQL语句列表

    /**
     * 单个SQL语句的验证项
     */
    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class StatementVerificationItem {
        private Integer statementNumber;    // 语句编号（关键匹配字段）
        private String sqlContent;         // 完整SQL内容
        private String sqlType;            // SQL类型：QUERY/DML/DDL等
        private String sourceType;         // 来源类型：MYBATIS_XML/JPA_ANNOTATION等
        private String sourceFile;         // 源文件路径
        private Integer lineNumber;        // 行号
        private List<RuleIssueItem> detectedIssues; // 该SQL检测到的所有规则问题
    }

    /**
     * 单个规则问题的详细信息
     */
    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    public static class RuleIssueItem {
        private String ruleId;             // 规则ID（关键匹配字段）
        private String ruleName;           // 规则名称
        private String category;           // 规则分类：DATATYPE/FUNCTION/SYNTAX/FEATURE
        private String severity;           // 严重程度：HIGH/MEDIUM/LOW/INFO
        private String rulePattern;        // 规则正则表达式
        private String ruleDescription;    // 规则描述
        private String ruleSuggestion;     // 规则建议
        private String issueDescription;   // 检测到的具体问题描述
        private String exampleSql;         // 规则示例SQL
        private String suggestedSql;       // 规则建议SQL
    }
}